import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../entity/lottery/lotter_result_bean.dart';
import '../../../utils/Tools.dart';

class LotteryResultFailDialogWidget extends StatefulWidget {
  final Function? onPress;
  final LotterResultBean? lotteryResultBean;

  LotteryResultFailDialogWidget(
      {super.key, required this.lotteryResultBean, this.onPress});

  @override
  _LotteryResultFailDialogWidgetState createState() =>
      _LotteryResultFailDialogWidgetState();
}

class _LotteryResultFailDialogWidgetState
    extends State<LotteryResultFailDialogWidget> with TickerProviderStateMixin {
  TabController? tabCtrLottery;
  bool isAll = true;

  @override
  void initState() {
    super.initState();
    tabCtrLottery = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: MediaQuery.of(Get.context!).size.width,
      // height: 500,
      decoration: BoxDecoration(
        // color: Tools.fromHex('#FFE8CE'), // 背景颜色
        borderRadius: BorderRadius.circular(8), // 设置圆角
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Stack(
            alignment: Alignment.center,
            children: [
              Image.asset("assets/images/ic_lottery_result_bg.png"),
              Container(
                child: Column(
                  // crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    SizedBox(
                      height: 50,
                    ),
                    Container(
                      width: 50,
                      height: 50,
                      child: Row(
                        children: [
                          Image.asset(
                            "assets/images/ic_lottery_fail.png",
                            width: 50,
                            height: 50,
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: 20,
                    ),
                    Text(
                      (widget.lotteryResultBean?.storage == 0 &&
                              (widget.lotteryResultBean?.name == null ||
                                  !Tools.checkEmpty(
                                      widget.lotteryResultBean?.name)))
                          ? '很遗憾，未能中奖'
                          : '很遗憾，奖品已被领取完',
                      style: TextStyle(
                          color: Tools.fromHex('#F83F2D'), fontSize: 20),
                    ),
                  ],
                ),
              )
            ],
          ),
          SizedBox(
            height: 10,
          ),
          GestureDetector(
            onTap: () {
              Navigator.pop(context);
              widget.onPress?.call();
            },
            child: Card(
              color: Colors.transparent,
              shadowColor: Colors.transparent,
              child: Container(
                width: 120,
                height: 40,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                  color: Tools.fromHex('#F83F2D'), // 背景颜色
                  borderRadius: BorderRadius.circular(20), // 设置圆角
                ),
                padding: EdgeInsets.symmetric(horizontal: 10, vertical: 4),
                child: Text(
                  '再抽一次',
                  style: TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.w500,
                      fontSize: 16),
                ),
              ),
            ),
          ),
          SizedBox(
            height: 10,
          ),
          GestureDetector(
            onTap: () {
              Navigator.pop(context);
            },
            child: Image.asset(
              "assets/images/close.png",
              color: Colors.white,
            ),
          )
        ],
      ),
    );
  }
}
